import request from '@/utils/request_admin'

const baseURL = '/user'

export default {
  login(data) {
    return request({
      url: `${baseURL}/login`,
      method: 'POST',
      data,
    })
  },
  getUserInfo(page, size) {
    return request({
      url: `${baseURL}/all/page`,
      method: 'GET',
      params: {
        page,
        size,
      },
    })
  },
  getAllUserInfo() {
    return request({
      url: `${baseURL}/all`,
      method: 'GET',
    })
  },
  checkNumber(userNumber) {
    return request({
      url: `${baseURL}/check/userNumber`,
      method: 'POST',
      params: {
        userNumber,
      },
    })
  },
  createUser(data) {
    return request({
      url: `${baseURL}/create`,
      method: 'POST',
      data,
    })
  },
  updateUser(data) {
    return request({
      url: `${baseURL}/update`,
      method: 'POST',
      data,
    })
  },
  deleteUser(userId) {
    return request({
      url: `${baseURL}/delete`,
      method: 'GET',
      params: {
        userId,
      },
    })
  },
  deleteBluk(userIds) {
    return request({
      url: `${baseURL}/delete/bluk`,
      method: 'POST',
      data: userIds,
    })
  },
  deletePermission(userId, permissionId) {
    return request({
      url: `${baseURL}/delete/permission`,
      method: 'GET',
      params: {
        userId,
        permissionId,
      },
    })
  },
  updatePermission(userId, permissionList) {
    return request({
      url: `${baseURL}/update` + `/permission`,
      method: 'POST',
      params: {
        userId,
      },
      data: permissionList,
    })
  },
}
